package com.bocek.chakmapoint.model;

import java.awt.Graphics;
import java.util.ArrayList;
import java.util.Collections;

public class Slide {

	private SlideItem currentCreation = null;
	private ArrayList<SlideItem> slideItems;
	private String name;

	public Slide() {
		this("Slide");
	}

	public Slide(String name) {
		this.name = name;
		slideItems = new ArrayList<SlideItem>();
	}

	public SlideItem getCurrentCreation() {
		return currentCreation;
	}

	public void setCurrentCreation(SlideItem currentCreation) {
		this.currentCreation = currentCreation;
	}

	public void finalizeCurrentCreation() {
		addSlideItem(currentCreation);
		currentCreation = null;
	}

	public ArrayList<SlideItem> getSlideItems() {
		return slideItems;
	}

	public ArrayList<SlideItem> getReverseSlideItems() {
		ArrayList<SlideItem> reverseSlideItems = new ArrayList<SlideItem>();

		for (SlideItem si : slideItems) {
			reverseSlideItems.add(si);
		}

		Collections.reverse(reverseSlideItems);

		return reverseSlideItems;
	}

	public void addSlideItem(SlideItem slideItem) {
		slideItems.add(slideItem);
	}

	public void removeSlideItem(SlideItem slideItem) {
		slideItems.remove(slideItem);
	}

	public void moveItemToFront(SlideItem slideItem) {
		if (slideItems.contains(slideItem)) {
			slideItems.remove(slideItem);
			slideItems.add(0, slideItem);
		}
	}

	public void moveItemToBack(SlideItem slideItem) {
		if (slideItems.contains(slideItem)) {
			slideItems.remove(slideItem);
			slideItems.add(slideItem);
		}
	}

	public String getName() {
		return name;
	}
}
